Cipheriv.[captureRejectionSymbol] method | Node.js crypto module | Bun
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
Cipheriv/
[captureRejectionSymbol]M[events.captureRejectionSymbol]
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
Cipheriv/
[captureRejectionSymbol]M[events.captureRejectionSymbol]
method
crypto.Cipheriv.[events.captureRejectionSymbol][events.captureRejectionSymbol](error:
Error,event: string | symbol,...args: any[]): void;
The Symbol.for('nodejs.rejection') method is called in case a promise rejection happens when emitting an event and captureRejections is enabled on the emitter. It is possible to use events.captureRejectionSymbol in place of Symbol.for('nodejs.rejection').
import { EventEmitter, captureRejectionSymbol } from 'node:events';
class MyClass extends EventEmitter {
constructor() {
super({ captureRejections: true });
}
[captureRejectionSymbol](err, event, ...args) {
console.log('rejection happened for', event, 'with', err, ...args);
this.destroy(err);
}
destroy(err) {
// Tear the resource down here.
}
}
Referenced typesinterface
Errorcause?: unknown
The cause of the error.
message: string
name: string
stack?: string
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →